<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page import="java.sql.*"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel="stylesheet" type="text/css" href="../css/public.css">
<title>修改管理员信息</title>
</head>
<script type="text/javascript">
function checkPwd()
{
	var pwd1 = document.getElementById("pwd1");
	var pwd2 = document.getElementById("pwd2");
	var PwdInfo = document.getElementById("PwdInfo");
	if(pwd1.value != pwd2.value)
		PwdInfo.innerHTML = "两次密码不一致请重新输入";
	else if(pwd1.value.length == 0)
		PwdInfo.innerHTML = "密码不能为空";
	else
		PwdInfo.innerHTML = "";
}
function updaCheck(){
	var pwd1 = document.getElementById("pwd1");
	var pwd2 = document.getElementById("pwd2");
	var PwdInfo = document.getElementById("PwdInfo");
	if(pwd1.value != pwd2.value)
		PwdInfo.innerHTML = "两次密码不一致请重新输入";
	else if(pwd1.value.length == 0)
		PwdInfo.innerHTML = "密码不能为空";
	else
	{
		PwdInfo.innerHTML = "";
		form1.action="studentupdate.jsp";
		form1.submit();
	}
}
</script>
<body>
<%
    String stuId = (String) session.getAttribute("stuId");
	if(stuId == null)
		out.println("<script>alert('没有登录,请重新登录！');window.location='../stuLogin.html'</script>");
	String stuName="";
    try
    {
	    Class.forName("com.mysql.jdbc.Driver").newInstance();
		Connection con = java.sql.DriverManager.getConnection("jdbc:mysql://localhost:3306/classfee", "root", "1234");
		Statement stmt = con.createStatement();
		ResultSet rs = stmt.executeQuery("SELECT * FROM  tb_student where stuId='"+stuId+"'");
		while(rs.next())
			stuName=rs.getString("stuName");
		rs.close();
%>
<div id="maincontent">
<div id="headGray">
<ul class="nopoint"><li><img src="../image/head.png" style="width:30px;height:30px"/><a id="maname" href="studentupdate1.jsp" style="color:white;text-decoration: none;"><% out.println(stuName);%></a><a href="../stulogout.jsp" style="margin-left:89%;color:white">退出登录</a></li></ul>
</div>
<div id="textArea-up">
<form method="post" name="form1">
<ul class="nopoint">
<li><label for="classId">所属班级:</label></li>
<li><select name="classId"  id="classId"><%ResultSet rst = stmt.executeQuery("SELECT * FROM  tb_class");while(rst.next()){ %><option value=<%out.println(rst.getInt("classId")); %>><%out.println(rst.getString("className"));%></option><%} rst.close();%></select></li>
<li><label for="stuName">姓名:</label></li>
<li><input name="stuName" type="text" id="stuName" value=<% out.println(stuName);%>></li>
<li><label for="stuSex">性别：</label></li>
<li><select  name="stuSex" id="stuSex"><option>男</option><option>女</option></select></li>
<li><label for="pwd1">修改密码：</label></li>
<li><input type="password" name="stuPwd" id="pwd1"></li>
<li><label for="pwd2">确认密码：</label><label id="PwdInfo" style="color:red"></label></li>
<li><input type="password" name="stuPwd2" id="pwd2" onblur="checkPwd()"></li>
<li id="libutton"><input type="button" value="修 改" onclick="updaCheck()"></li>
</ul>
</form>
</div>
</div>
<%	
    stmt.close();
    con.close();
	}
    catch (Exception e)
    {
    	out.println(e.getMessage());
    }
 %>
</body>
</html>